define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'log/money_log/index'
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                search:false,
                columns: [
                    [
                        {field: 'id', title: 'ID',sortable:true},
                        {field: 'desc', title: __('Desc'),sortable:false},
                        {field: 'user_nickname', title: __('User nickname'),searchable:false},
                        {field: 'source_nickname', title: __('Source nickname'),searchable:false},
                        {field: 'user_id', title: __('User nickname ID')},
                        {field: 'source_id', title: __('Source nickname ID')},
                        {field: 'current_money', title: __('Current money'),searchable:false},
                        {field: 'money', title: __('Money'),searchable:false},
                        {field: 'change_type', title: __('Change type'),formatter:function(value,row,index){
                            value = value + '';
                            switch (value){
                                case '0':
                                    return __('New user answer');
                                case '1':
                                    return __('Promote');
                                case '2':
                                    return __('Withdrawal');
                                case '3':
                                    return __('Answer type');
                                case '4':
                                    return __('Answer success');
                                case '5':
                                    return __('Pay answer');
                                case '6':
                                    return __('Withdrawal failure');
                                case '7':
                                    return __('Red withdrawal');
                                default:
                                    return __('New user answer');
                            }
                        },searchList: {'0': __('New user answer'), '1': __('Promote'),'2': __('Withdrawal'), '3': __('Answer failure'), '4': __('Answer success'), '5': __('Pay answer'), '6': __('Withdrawal failure'),'7':__('Red withdrawal')}, style: 'min-width:100px;'
                        },
                        {field: 'money_type', title: __('Money type'),formatter:function(value,row,index){
                            value = value + '';
                            switch (value){
                                case '0':
                                    return __('Challenge card');
                                case '1':
                                    return __('Balance');
                                default:
                                    return __('Challenge card');
                            }
                        },searchList: {'0': __('Challenge card'), '1': __('Balance')}, style: 'min-width:100px;'
                        },
                        {field: 'in_out_type', title: __('In out type'),formatter:function(value,row,index){
                            value = value + '';
                            switch (value){
                                case '0':
                                    return __('In');
                                case '1':
                                    return __('Out');
                                default:
                                    return __('In');
                            }
                        },searchList: {'0': __('In'), '1': __('Out')}, style: 'min-width:100px;'
                        },
                        {field: 'create_time', title: __('Create time'),
                            formatter: Table.api.formatter.datetime, operate: 'BETWEEN',
                            type: 'datetime', addclass: 'datetimepicker',
                            data: 'data-date-format="YYYY-MM-DD"'
                        }
                    ]
                ]
            });
            // 为表格绑定事件
            Table.api.bindevent(table);
        }
    };
    return Controller;
});